<?php
$bookableMessage = new BWMessage($bookableId);
$priceAdjustTable = new BASheet('priceAdjust', $bookableMessage);
if (isset($priceAdjustId) && $priceAdjustId > 0) {
    $priceAdjust = $priceAdjustTable->getListById($priceAdjustId);
}

$model = new BDynamicFormModel();
$nameField = 'media_name_priceAdjust';
$descriptionField = 'media_description_priceAdjust';
$adjustModeField = 'media_adjustMode_priceAdjust';
$adjustAmountField = 'media_adjustAmount_priceAdjust';
$model->addField($nameField);
$model->addField($descriptionField);
$model->addField($adjustModeField);
$model->addField($adjustAmountField);

if (isset($priceAdjust)) {
    $model->$nameField = $priceAdjust->getItem('name')->getValue();
    $model->$descriptionField = $priceAdjust->getItem('description')->getValue();
    $model->$adjustModeField = $priceAdjust->getItem('adjustMode')->getValue();
    $model->$adjustAmountField = $priceAdjust->getItem('adjustAmount')->getValue();
}
?>

<p class="text-right"><?php
    echo $control->getAjaxLink(
            array('name' => '价格调整列表', 'id' => 'showPriceAdjustList'), array(
        'bookableId' => $bookableId
    ));
    ?>|设置价格调整
    <?php
    if ($priceAdjustId > 0) {
        echo '|';
        echo $control->getAjaxLink(array('name' => '会员列表', 'id' => 'showRoleList'), array(
            'bookableId' => $bookableId,
            'priceAdjustId' => $priceAdjustId
        ));
        ?>
        <?php
        echo '|';
        echo $control->getAjaxLink(array('name' => '最后价格表', 'id' => 'showFinalPriceList'), array(
            'bookableId' => $bookableId,
            'priceAdjustId' => $priceAdjustId
        ));
    }
    ?>
    
</p>


<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "message-form",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<table class="table table-hover">
    <colgroup>
        <col class="span1">
        <col class="span7">
    </colgroup>
    <thead>
    </thead>
    <tbody>
        <tr>
            <td>
                名称
            </td>
            <td>
                <?php echo CHtml::activeTextField($model, $nameField); ?>
            </td>
        </tr>
        <tr><td>描述</td>
            <td>
                <?php echo CHtml::activeTextArea($model, $descriptionField); ?>
            </td>
        </tr> 
        <tr><td>调整方式 </td>
            <td>
                <?php
                $adjustModeList = BAPriceAdjust::getAdjustModeList();
                echo CHtml::activeDropDownList($model, $adjustModeField, $adjustModeList);
                ?>
            </td>
        </tr>
        <tr><td> 价格调整量 </td>
            <td>
                <?php echo CHtml::activeTextField($model, $adjustAmountField); ?>
            </td>
        </tr>
    </tbody>
</table> 
<div class="row-fluid">
    <?php
    echo $control->getAjaxLink(array('name' => '保存价格调整', 'id' => 'savePriceAdjust'), array(
        'bookableId' => $bookableId,
        'htmlOptions' => array('class' => 'btn')));
    ?>
    
</div>
<?php $this->endWidget(); ?>